Skip to content

Introduce TOML-based configuration to replace data.py - #491

Draft
glehmann wants to merge 14 commits into
gln/typehints-nextfrom
gln/config-migration-to-toml-mxrr
Draft

Introduce TOML-based configuration to replace data.py#491
glehmann wants to merge 14 commits into
gln/typehints-nextfrom
gln/config-migration-to-toml-mxrr

Conversation

@glehmann

@glehmann glehmann commented Apr 21, 2026

Copy link
Copy Markdown
Member

The previous data.py approach had several shortcomings:

  • No base configuration: users had to start from scratch or copy data.py-dist
  • No environment management: working with multiple infra required to manually
    copy the data.py files
  • No clear default and customization separation: the data.py, once copied
    from data.py-dist and customized, was mixing the defaults and the
    customizations

The new TOML config system addresses this by:

  • Providing a base config.toml maintained by the project with sensible defaults,
    which can be updated without user action
  • Supporting per-environment override files (config..toml) so users only
    specify what differs from the defaults, making their customizations explicit

Options have been grouped by sections for clarity.

Configuration sections and their contents:

  • [host]: default XAPI credentials (user, password)
  • [hosts]: per-host credential overrides
  • [network]: management network name
  • [pxe]: PXE server settings (arp_server)
  • [vm]: VM settings (default_sr, images, equivalents, def_url)
  • [install]: installer settings (answerfiles, iso_remaster, isos)
  • [guest_tools]: guest tools packages and installer ISOs (win, other, installed, download_url)
  • [ssh]: SSH client settings (pubkey, output_max_lines, ignore_banner)
  • [storage]: storage backend configs (nfs, nfs4, nfs_iso, cifs_iso, cephfs, moosefs, lvmoiscsi)
  • Root keys: objects_name_prefix, dns_server

Also includes config-schema.json, lib/config_loader.py (Pydantic models),
and scripts/migrate_data_py.py to help users migrate from data.py.

Comment thread config-schema.json Outdated
"type": "object",
"properties": {
"path": { "type": "string" },
"net-url": { "type": "string" },

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe you should choose a convention "snake_case" or "kebab-case", what do you think?

@glehmann
glehmann force-pushed the gln/config-migration-to-toml-mxrr branch from ee666c4 to ed2606e Compare May 11, 2026 15:48
@glehmann
glehmann force-pushed the gln/passlib-integration-kuyq branch from 789db8a to ff81a81 Compare May 11, 2026 15:48
@glehmann
glehmann force-pushed the gln/config-migration-to-toml-mxrr branch from ed2606e to 8c9e4e8 Compare May 12, 2026 13:16
@glehmann
glehmann force-pushed the gln/passlib-integration-kuyq branch from ff81a81 to 4b18836 Compare May 12, 2026 17:08
@glehmann
glehmann force-pushed the gln/config-migration-to-toml-mxrr branch from 8c9e4e8 to 1271dc5 Compare May 12, 2026 17:08
@glehmann
glehmann force-pushed the gln/passlib-integration-kuyq branch from 4b18836 to 78b593a Compare May 13, 2026 13:58
@glehmann
glehmann force-pushed the gln/config-migration-to-toml-mxrr branch 2 times, most recently from 5edbb05 to 7884b4e Compare May 13, 2026 14:20
@glehmann
glehmann force-pushed the gln/config-migration-to-toml-mxrr branch 2 times, most recently from b6a447b to 64dafbe Compare May 19, 2026 15:29
@glehmann
glehmann force-pushed the gln/passlib-integration-kuyq branch from 6aa0263 to f378395 Compare May 19, 2026 15:37
@glehmann
glehmann force-pushed the gln/config-migration-to-toml-mxrr branch 2 times, most recently from 01ba89d to 295d469 Compare May 20, 2026 19:02
@glehmann
glehmann force-pushed the gln/passlib-integration-kuyq branch 2 times, most recently from 123e95d to f1dc1d7 Compare May 22, 2026 15:29
@glehmann
glehmann force-pushed the gln/config-migration-to-toml-mxrr branch 2 times, most recently from 837291c to f3cdfc7 Compare May 22, 2026 16:59
@glehmann
glehmann force-pushed the gln/passlib-integration-kuyq branch from f1dc1d7 to 406cf12 Compare May 22, 2026 16:59
@glehmann
glehmann force-pushed the gln/config-migration-to-toml-mxrr branch from f3cdfc7 to 912c91c Compare May 29, 2026 11:37
@glehmann
glehmann force-pushed the gln/passlib-integration-kuyq branch from 406cf12 to 435faac Compare May 29, 2026 11:37
@glehmann
glehmann force-pushed the gln/config-migration-to-toml-mxrr branch 2 times, most recently from 3430eec to 9073a88 Compare June 10, 2026 08:57
@glehmann
glehmann force-pushed the gln/passlib-integration-kuyq branch from 903b4d8 to 4004073 Compare June 10, 2026 08:57
Base automatically changed from gln/passlib-integration-kuyq to master July 8, 2026 20:45
@glehmann
glehmann force-pushed the gln/config-migration-to-toml-mxrr branch from 9073a88 to ef7ae50 Compare August 18, 2026 10:08
@ydirson
ydirson self-requested a review August 19, 2026 08:16
@glehmann
glehmann force-pushed the gln/config-migration-to-toml-mxrr branch 3 times, most recently from 026f4b5 to 2f66aee Compare August 20, 2026 21:55
@glehmann
glehmann changed the base branch from master to gln/typehints-next August 20, 2026 21:58
@glehmann
glehmann force-pushed the gln/config-migration-to-toml-mxrr branch from 2f66aee to cc37fcb Compare August 25, 2026 20:01
@glehmann
glehmann force-pushed the gln/typehints-next branch 2 times, most recently from 564f75e to d7096af Compare August 25, 2026 20:59
@glehmann
glehmann force-pushed the gln/config-migration-to-toml-mxrr branch from b903273 to 5d73dfd Compare August 25, 2026 20:59
The previous data.py approach had several shortcomings:
- No base configuration: users had to start from scratch or copy data.py-dist
- No environment management: working with multiple infra required to manually
  copy the data.py files
- No clear default and customization separation: the data.py, once copied
  from data.py-dist and customized, was mixing the defaults and the
  customizations

The new TOML config system addresses this by:
- Providing a base config.toml maintained by the project with sensible defaults,
  which can be updated without user action
- Supporting per-environment override files (config.<name>.toml) so users only
  specify what differs from the defaults, making their customizations explicit

Options have been grouped by sections for clarity.

Configuration sections and their contents:
- [host]: default XAPI credentials (user, password)
- [hosts]: per-host credential overrides
- [network]: management network name
- [pxe]: PXE server settings (arp_server)
- [vm]: VM settings (default_sr, images, equivalents, def_url)
- [install]: installer settings (answerfiles, iso_remaster, isos)
- [guest_tools]: guest tools packages and installer ISOs (win, other, installed, download_url)
- [ssh]: SSH client settings (pubkey, output_max_lines, ignore_banner)
- [storage]: storage backend configs (nfs, nfs4, nfs_iso, cifs_iso, cephfs, moosefs, lvmoiscsi)
- Root keys: objects_name_prefix, dns_server

Also includes lib/config_loader.py (Pydantic models) to validate the
configuration.

Signed-off-by: Gaëtan Lehmann <gaetan.lehmann@vates.tech>
To make easier editing within our editors.
This format is compatible with multiple toml lsp, including taplo.

Signed-off-by: Gaëtan Lehmann <gaetan.lehmann@vates.tech>
Signed-off-by: Gaëtan Lehmann <gaetan.lehmann@vates.tech>
Configuration is now done in config.toml and config.*.toml

Signed-off-by: Gaëtan Lehmann <gaetan.lehmann@vates.tech>
Config files can now reference other TOML files via a root-level
`include` array.  Included files are deep-merged before the
including file's own content, with paths resolved relative to
the including file's directory.  Cycle detection prevents infinite
recursion.  Both `config.toml` and `config.{name}.toml` override
files support this mechanism.

Signed-off-by: Gaëtan Lehmann <gaetan.lehmann@vates.tech>
Configuration values can now be overridden at runtime with
`XCPNG_TESTS_`-prefixed environment variables.
Double underscores separate path segments (e.g.
`XCPNG_TESTS_network__free_nics='["eth1"]'` overrides
`config.network.free_nics`).

Values are parsed as TOML when possible, falling back to
plain strings - so booleans, integers, arrays, and inline
tables work naturally alongside plain string values.

Signed-off-by: Gaëtan Lehmann <gaetan.lehmann@vates.tech>
The config file now holds the inventory: [default] provides default
repositories/hosting_pool settings applied to all hosts, [hosts] lists
the pool masters to run against, and both pytest and tools.py read from
it. --config/-c accepts a profile name or a .toml file path anywhere on
disk; config.local.toml is auto-merged when no override is given, and
include paths resolve relative to the including file first, then the repo
root.

- tools.py: -i/--inventory removed; -H still overrides, -e/-x/-P act as
  temporary overrides; clean/exec fall back to config hosts too
- conftest: hosts fixture uses config [hosts] when --hosts is empty
- host_data(): fall back to default user/password for bare [hosts] entries
- schema: overlays validate without required keys while typos stay flagged
  (additionalProperties: false); new [default] section
- update task: guard against an empty pool list
- config.toml, README: document the new layout

Signed-off-by: Gaëtan Lehmann <gaetan.lehmann@vates.tech>
-c NAME / XCPNG_CONFIG=NAME now looks up config.NAME.toml in the directory
given by the XCPNG_CONFIG_DIR env var when it is set, then in the xcp-ng-tests
repository root. A value that matches a file is otherwise used as a path
relative to the current directory; the repository root and current directory
are no longer searched for profile names.

Documented in the README's configuration section.

Signed-off-by: Gaëtan Lehmann <gaetan.lehmann@vates.tech>
Allow selecting a config overlay via the XCPNG_CONFIG environment variable,
equivalent to the --config flag. Update docs and CLI help accordingly.

Signed-off-by: Gaëtan Lehmann <gaetan.lehmann@vates.tech>
…against the base

`tools.py dump-config` prints the final configuration (base config.toml +
layered includes + overrides) as TOML, or JSON with --json; the TOML output
is deterministically ordered and syntax-colored on TTYs (--color/--no-color
to force). dump-config and migrate-data-py now print only values that differ
from the base config.toml, with --all restoring the full config. The shared
helpers (remove_defaults, deep_dict_equal, _strip_password_hashes) live in
lib/config_dump, and load_config gains apply_value_overrides=False to compute
the base config without XCPNG_TESTS_* / --config-value overlays.

Signed-off-by: Gaëtan Lehmann <gaetan.lehmann@vates.tech>
--config-value KEY=VALUE overrides a single config value at runtime, with the
KEY being a dotted path (double quotes around segments that contain dots).
Values are parsed as TOML, so booleans, numbers, arrays and inline tables
work too. Precedence is config.toml < overlay < XCPNG_TESTS_* env vars <
--config-value. Wired into pytest (--config-value) and tools.py; the override
is applied before the password hash is computed, so default_password and
default_password_hash stay consistent.

Documented in the README's configuration section.

Signed-off-by: Gaëtan Lehmann <gaetan.lehmann@vates.tech>
diff-config CONFIG1 CONFIG2 prints a unified diff between two resolved
configs, ignoring password hashes; TOML by default, --json for JSON
representation. Exits 0 when the configs are identical, 1 otherwise.
Configs are loaded without value/env overrides so both sides are compared
on their own contents.

Signed-off-by: Gaëtan Lehmann <gaetan.lehmann@vates.tech>
Make jobs.py use the same configuration as pytest and tools.py: -c/--config,
XCPNG_CONFIG/XCPNG_CONFIG_DIR and --config-value are now accepted, and
jobs.py run falls back to the hosts defined in the config's [hosts] section
when no hosts are given explicitly. Documented in the README.

Signed-off-by: Gaëtan Lehmann <gaetan.lehmann@vates.tech>
A config written for a newer version of the project may contain keys this
version does not support. Load it anyway, dropping the unknown keys with a
warning instead of aborting, so the same config can be shared across project
versions.

Signed-off-by: Gaëtan Lehmann <gaetan.lehmann@vates.tech>
@glehmann
glehmann force-pushed the gln/config-migration-to-toml-mxrr branch from 5d73dfd to eef21f1 Compare August 30, 2026 20:15
@glehmann
glehmann force-pushed the gln/typehints-next branch from d7096af to 2e63777 Compare August 30, 2026 20:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants